
# generate table 1

# load packages
library(rio) # load data
library(tidyverse) # data manipulation
library(fect) # estimate difference in differences
library(knitr) # generate table to export results

# set working directory
setwd("~/replication_files/")

# load data for analysis
data_with_dictionary <- import("data/full_data.csv") 

# model 1, table 1
fect1 <- fect(policy_passage ~ article_iv_promotes_governance_lag + imf_program + field_discovery_lag + log_gdp_per_capita_lag  + gdp_growth_lag,
                    data = data_with_dictionary, index = c("iso3c","year"),
                    method = "fe", force = "two-way", seed = 1904,
                    se = TRUE, nboots = 1000)

# model 2, table 1
fect2 <- fect(policy_passage ~ article_iv_mentions_resources_lag + imf_program + field_discovery_lag + log_gdp_per_capita_lag + gdp_growth_lag, 
              data = data_with_dictionary, index = c("iso3c","year"), 
              method = "fe", force = "two-way", seed = 1904,
              se = TRUE, nboots = 1000)

# generate table 1
rbind(fect1$est.avg, # average treatment effect on the treated
      fect1$est.beta) %>% # effect of covariates
  kable(digits=3)
fect1$N # number of units
fect1$T # number of time periods

rbind(fect2$est.avg, # average treatment effect on the treated
      fect2$est.beta) %>% # effect of covariates
  kable(digits=3)
fect1$N # number of units
fect1$T # number of time periods


